package com.xopencode.account.service.impl;

import com.xopencode.account.client.OrderClient;
import com.xopencode.account.dao.AccountDao;
import com.xopencode.account.service.AccountService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Mcb
 * @date 2022/4/23
 * @apiNote
 */
@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;
    @Autowired
    private OrderClient orderClient;

    @Override
    @GlobalTransactional
    public void changeAccount(int id, int number) {
        accountDao.changeAccount(id, number);
        //制造错误，测试回滚
        int i = 1/0;
        orderClient.addOrder(1);
    }
}
